/*
 * DevilInterpreter.h
 *
 *  Created on: Oct 19, 2012
 *      Author: wenwei
 */

#ifndef DEVILINTERPRETER_H_
#define DEVILINTERPRETER_H_

#include <istream>
#include "CxxUtils.h"
#include "SkBitmap.h"
#include "PostscriptDoc.h"
#include "DevilSemantic.h"

using namespace std;

class DevilInterpreter
{
protected:
	DevilInterpreter(const DevilInterpreter&);
	DevilInterpreter& operator=(const DevilInterpreter&);
	
	SkBitmap mPageBitmap;
	
	DevilSemantic mSemantics;
	
	PostscriptDoc mDoc;
	
	CRefPtr< std::istream > mInput;
	
	void extractPage(std::streampos start, std::streampos end, std::string& out);
public:
	DevilInterpreter();
	virtual ~DevilInterpreter();

	void setPostscript(CRefPtr< std::istream > is);
	
	const PostscriptDoc& getDocument() const {
		return mDoc;
	}
	
	void renderPage(size_t pageNo, float scale, SkBitmap& outBitmap);
};

#endif /* DEVILINTERPRETER_H_ */
